home *** CD-ROM | disk | FTP | other *** search
/ Great Canadian Scientists / GCS_CD.iso / mac / PC / GCSData / menus_o.dxr / 00101_Main Scripts.ls < prev    next >
Encoding:
Text File  |  1996-09-08  |  6.8 KB  |  273 lines

  1. on startMovie
  2.   global CR, Sep, CDLocation, NoQuiz, FirstQuiz, LengthOfFile, sync, BoxUp
  3.   if the machineType = 256 then
  4.     set the transitionType of member 52 of castLib 2 to 26
  5.     set CR to RETURN & numToChar(10)
  6.     set Sep to "\"
  7.     openXLib(CDLocation & "OTHER\FILEIO.DLL")
  8.   else
  9.     set the transitionType of member 52 of castLib 2 to 23
  10.     set CR to RETURN
  11.     set Sep to ":"
  12.   end if
  13.   set LengthOfFile to 15
  14.   if the frame > 15 then
  15.     SoundControl()
  16.   end if
  17.   HideScore()
  18.   set FirstQuiz to 0
  19.   set NoQuiz to 0
  20.   set sync to 0
  21.   set BoxUp to 0
  22.   set the fileName of member 34 of castLib 2 to CDLocation & "Movies&Sep&Clock.mov"
  23. end
  24.  
  25. on InputName
  26.   global LengthOfFile, name, BoxUp, OpenType, Difficulty, Screen, AutoQuiz, NewScores, ReadScores, Temp, Counter, Error, PopQuizTime, NoQuiz, QuizWaiting, TimeToQuiz
  27.   BSuspend(18, 19)
  28.   set the visible of sprite 23 to 1
  29.   set the visible of sprite 17 to 1
  30.   go("BoxDown")
  31.   set fileName to line 1 of field "FileName"
  32.   if OpenType = "New" then
  33.     if length(line 1 of field "FileName") <= 2 then
  34.       beep()
  35.       put "I'm sorry.  That name is too short.  Please try another name." into field "MsgBox"
  36.       set Error to 1
  37.       go("Error")
  38.       set the visible of sprite 23 to 0
  39.       exit
  40.     end if
  41.     set NewScores to FileIO(mnew, "?write", fileName)
  42.     cursor(4)
  43.     if NewScores < 0 then
  44.       CancelBox()
  45.       cursor(-1)
  46.       exit
  47.     end if
  48.     NewScoreFile()
  49.   end if
  50.   set Error to 0
  51.   if OpenType = "New" then
  52.     set ReadScores to FileIO(mnew, "read", name)
  53.   end if
  54.   cursor(4)
  55.   if OpenType <> "New" then
  56.     if the machineType = 256 then
  57.       set ReadScores to FileIO(mnew, "?read", "txt")
  58.     else
  59.       set ReadScores to FileIO(mnew, "?read", "TEXT")
  60.     end if
  61.     if ReadScores < 0 then
  62.       CancelBox()
  63.       cursor(-1)
  64.       exit
  65.     end if
  66.     set name to ReadScores(mFileName)
  67.   end if
  68.   repeat with Counter = 1 to LengthOfFile + 1
  69.     set Temp to ReadScores(mReadLine)
  70.     if (Counter = 1) and (Temp <> ("Great Canadian Scientists Player Record" & RETURN)) then
  71.       FileError(0)
  72.     end if
  73.     if (Temp = EMPTY) and (Counter <= LengthOfFile) then
  74.       FileError(1)
  75.     end if
  76.     if (Temp <> EMPTY) and (Counter > LengthOfFile) then
  77.       FileError(2)
  78.     end if
  79.     if the result = 1 then
  80.       put "ERROR"
  81.       exit
  82.     end if
  83.   end repeat
  84.   ReadScoreFile()
  85.   set BoxUp to 0
  86.   set AutoQuiz to 1
  87.   if OpenType = "New" then
  88.     go("Main Menu Intro")
  89.   end if
  90.   if OpenType = "Open" then
  91.     go("Main Menu")
  92.   end if
  93.   set PopQuizTime to the ticks
  94.   set NoQuiz to 0
  95.   set QuizWaiting to 0
  96.   SetTimeToQuiz()
  97. end
  98.  
  99. on ReadScoreFile
  100.   global name, Difficulty, Screen, DataBaseEnter, sound, SoundFX, QuizFreq, SalmonFishing, PatternMatching, ChromosomePairing, MemoryTesting, MapAnalysing, RhombusTiling, AtomReacting, PopQuizScore
  101.   set ReadScores to FileIO(mnew, "read", name)
  102.   set IDLine to ReadScores(mReadLine)
  103.   set Difficulty to value(ReadScores(mReadLine))
  104.   set Screen to value(ReadScores(mReadLine))
  105.   set DataBaseEnter to value(ReadScores(mReadLine))
  106.   set sound to value(ReadScores(mReadLine))
  107.   set SoundFX to value(ReadScores(mReadLine))
  108.   set QuizFreq to value(ReadScores(mReadLine))
  109.   set SalmonFishing to value(ReadScores(mReadLine))
  110.   set MemoryTesting to value(ReadScores(mReadLine))
  111.   set ChromosomePairing to value(ReadScores(mReadLine))
  112.   set PatternMatching to value(ReadScores(mReadLine))
  113.   set MapAnalysing to value(ReadScores(mReadLine))
  114.   set RhombusTiling to value(ReadScores(mReadLine))
  115.   set AtomReacting to value(ReadScores(mReadLine))
  116.   set PopQuizScore to value(ReadScores(mReadLine))
  117.   ReadScores(mdispose)
  118. end
  119.  
  120. on NewScoreFile
  121.   global Difficulty, name, CR
  122.   set name to NewScores(mFileName)
  123.   NewScores(mWriteString, "Great Canadian Scientists Player Record" & CR)
  124.   NewScores(mWriteString, Difficulty & CR)
  125.   NewScores(mWriteString, "0" & CR)
  126.   NewScores(mWriteString, "0" & CR)
  127.   NewScores(mWriteString, "1" & CR)
  128.   NewScores(mWriteString, "3" & CR)
  129.   NewScores(mWriteString, "1" & CR)
  130.   NewScores(mWriteString, "0" & CR)
  131.   NewScores(mWriteString, "0" & CR)
  132.   NewScores(mWriteString, "0" & CR)
  133.   NewScores(mWriteString, "0" & CR)
  134.   NewScores(mWriteString, "0" & CR)
  135.   NewScores(mWriteString, "0" & CR)
  136.   NewScores(mWriteString, "0" & CR)
  137.   NewScores(mWriteString, "0")
  138.   NewScores(mdispose)
  139. end
  140.  
  141. on FileError Num
  142.   beep()
  143.   put Num
  144.   ReadScores(mdispose)
  145.   put "I'm sorry, something is wrong with your record.  Please create a new record." into field "MsgBox"
  146.   cursor(-1)
  147.   go("Error")
  148.   return 1
  149. end
  150.  
  151. on CancelBox
  152.   global BoxUp
  153.   set the visible of sprite 23 to 1
  154.   set the visible of sprite 17 to 1
  155.   BSetup(8, 9)
  156.   BSuspend(18, 19)
  157.   go("BoxDown")
  158.   set BoxUp to 0
  159. end
  160.  
  161. on KeyCheck
  162.   global BoxUp
  163.   if BoxUp = 1 then
  164.     if the key = RETURN then
  165.       InputName()
  166.     end if
  167.     if the keyCode = 53 then
  168.       CancelBox()
  169.       dontPassEvent()
  170.     end if
  171.   end if
  172. end
  173.  
  174. on KeyCheckE
  175.   global BoxUp
  176.   if BoxUp = 1 then
  177.     if the key = RETURN then
  178.       ShowBox()
  179.     end if
  180.   end if
  181. end
  182.  
  183. on ShowBox
  184.   global Error, BoxUp
  185.   BSuspend(22, 22)
  186.   if Error = 1 then
  187.     go("BoxUp")
  188.   end if
  189.   if Error = 0 then
  190.     set BoxUp to 0
  191.     go("BoxDown")
  192.     BSetup(8, 9)
  193.   end if
  194. end
  195.  
  196. on idle
  197.   if the frame > 80 then
  198.     PopIdle()
  199.   end if
  200.   SoundLoop()
  201. end
  202.  
  203. on NoPass
  204.   dontPassEvent()
  205. end
  206.  
  207. on Help
  208.   cursor(4)
  209.   go("Main Menu Help")
  210. end
  211.  
  212. on CheckRollover
  213.   set on to 0
  214.   repeat with count = 25 down to 14
  215.     if on = 0 then
  216.       if rollOver(count) = 1 then
  217.         if (the castNum of sprite (count - 12) mod 3) = 1 then
  218.           set the castNum of sprite (count - 12) to the castNum of sprite (count - 12) + 1
  219.         end if
  220.         if the stillDown = 0 then
  221.           if (the castNum of sprite (count - 12) mod 3) = 0 then
  222.             set the castNum of sprite (count - 12) to the castNum of sprite (count - 12) - 1
  223.           end if
  224.         else
  225.           if (the castNum of sprite (count - 12) mod 3) = 2 then
  226.             set the castNum of sprite (count - 12) to the castNum of sprite (count - 12) + 1
  227.           end if
  228.         end if
  229.         set on to 1
  230.       else
  231.         ResetButtons(count)
  232.       end if
  233.       next repeat
  234.     end if
  235.     ResetButtons(count)
  236.   end repeat
  237. end
  238.  
  239. on ResetButtons count
  240.   if (the castNum of sprite (count - 12) mod 3) = 2 then
  241.     set the castNum of sprite (count - 12) to the castNum of sprite (count - 12) - 1
  242.   end if
  243.   if (the castNum of sprite (count - 12) mod 3) = 0 then
  244.     set the castNum of sprite (count - 12) to the castNum of sprite (count - 12) - 2
  245.   end if
  246. end
  247.  
  248. on RestartProgram
  249.   global name, Screen, sync, FirstQuiz, sound, SoundFX, QuizFreq, Difficulty
  250.   cursor(4)
  251.   BSuspend(30, 41)
  252.   BSuspend(7, 18)
  253.   BSuspend(22, 25)
  254.   BSuspend(47, 48)
  255.   ScoreToFile()
  256.   set FirstQuiz to 0
  257.   set QuizFreq to 1
  258.   set sound to 3
  259.   set SoundFX to 3
  260.   set sync to 0
  261.   set Screen to 0
  262.   set Difficulty to 1
  263.   SoundControl()
  264.   updateStage()
  265.   go("Startup Menu")
  266.   set name to EMPTY
  267.   cursor(-1)
  268. end
  269.  
  270. on GoMain
  271.   go("Main From Intro")
  272. end
  273.